package com.android.slidingmenuexample;

import java.util.ArrayList;

import com.android.slidingmenuexample.menuactivities.Notice;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

 
public class NoticeAdapter extends BaseAdapter implements OnClickListener{
 
	private Notice mNotice;
	private Context mContext;
	
	private TextView tvNoticeDate;
	private TextView tvNoticeTitle;
	//private TextView tvNoticeBody;
	
	private ArrayList<Notice> mNoticeData;
	
	public NoticeAdapter(Context context) {
		super();
		mContext = context;
		mNoticeData = new ArrayList<Notice>();
	}
	
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return mNoticeData.size();
	}
	
	@Override
	public Notice getItem(int position) {
        return mNoticeData.get(position);
    }
	
	@Override
	public long getItemId(int position) {
        return 0;
    }

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		View v = convertView;
	
		if (v == null) {
			v = ((LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE))
					.inflate(R.layout.notice, null);

			tvNoticeDate = (TextView) v.findViewById(R.id.NoticeDate);
			tvNoticeTitle = (TextView) v.findViewById(R.id.NoticeTitle);
		}
	
		mNotice = getItem(position);

		if ( mNotice != null ){
			
			tvNoticeDate.setText(mNotice.getNoticeDate());
			tvNoticeTitle.setText(mNotice.getNoticeTitle());
			//btnSend.setOnClickListener(this);
		}
		// �꾩꽦���꾩씠��酉곕� 諛섑솚�⑸땲��
		return v;
	}
	
	// �곗씠�곕� 異붽��섎뒗 寃껋쓣 �꾪빐��留뚮뱾��以�떎.
	public void add(Notice Notice){
		mNoticeData.add(Notice);
	}

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		
		/*
		// Tag瑜��댁슜�섏뿬 Data瑜�媛�졇�듬땲�� 
		Notice clickItem = (Notice)v.getTag();
		
		switch (v.getId()){
			case R.id.btn_send:
				Toast.makeText(mContext, clickItem.getNoticePhoneNumber(), Toast.LENGTH_SHORT).show();
				break;
		} */
	}
	
}
